package com.hrs.core.controller;

import com.hrs.common.constant.SwaggerConst;
import com.hrs.common.doMain.PageResultDto;
import com.hrs.common.result.Result;
import com.hrs.core.service.AchieveService;
import com.hrs.enity.dto.AchieveAddDto;
import com.hrs.enity.dto.AchieveUpdateDto;
import com.hrs.enity.dto.AchieveViewDto;
import com.hrs.enity.ro.AchievePageRo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;

/**
 * @author 摆渡人
 * @description
 * @date 2022/12/6 13:05
 */
@Slf4j
@Validated
@Api(tags = {SwaggerConst.Admin.MANAGER_ACHIEVE})
@RestController
public class AchieveController {

    @Autowired
    private AchieveService achieveService;

    @ApiOperation(value = "增添", notes = "@author 摆渡人 使用者：人事专员")
    @PostMapping("/achieve/add")
    public Result<String> add(@RequestBody AchieveAddDto achieveAddDto) {
        return achieveService.add(achieveAddDto);
    }

    @ApiOperation(value = "复核", notes = "@author 摆渡人 使用者：人事经理")
    @PostMapping("/achieve/review")
    public Result<String> review(@RequestBody AchieveUpdateDto achieveUpdateDto) {
        return achieveService.review(achieveUpdateDto);
    }

    @ApiOperation(value = "查询")
    @PostMapping("/achieve/page")
    public Result<PageResultDto<AchieveViewDto>> pageAchieve(@Validated @RequestBody AchievePageRo achievePageRo){
        return achieveService.pageAchieve(achievePageRo);
    }

    @ApiOperation(value = "变更")
    @PostMapping("/achieve/update")
    public Result<String> updateAchieve(@Validated @RequestBody AchieveUpdateDto achieveUpdateDto){
        return achieveService.updateAchieve(achieveUpdateDto);
    }

    @ApiOperation(value = "删除")
    @PostMapping("/achieve/delete")
    public Result<String> deleteAchieve(@NotNull Long id) {
        return achieveService.delete(id);
    }

    @ApiOperation(value = "恢复")
    @PostMapping("/achieve/recover")
    public Result<String> recoverAchieve(@NotNull Long id) {
        return achieveService.recoverAchieve(id);
    }

    @ApiOperation(value = "根据id获取一条档案信息",notes = "@author 摆渡人")
    @GetMapping("/achieve/get/{id}")
    public Result<AchieveViewDto> get(@PathVariable("id") Long id){
        return achieveService.get(id);
    }
}
